<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*,java.util.*"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Talk to Master</title>
</head>
<body>

<%
  Connection conn = null;
  Statement stmt = null;

  Class.forName("com.mysql.jdbc.Driver");
  conn = DriverManager.getConnection("jdbc:mysql://140.119.19.171/klp","case", "12345");
  stmt = conn.createStatement();
  String sql1 = "SELECT distinct c.C_No , c.C_Name FROM klp.course c , klp.elective e  where e.C_No = c.C_No AND e.Stu_Id = '" + (String)session.getAttribute("StudentID") + "'";
  ResultSet rs = stmt.executeQuery(sql1);  
 
%>

<script language="javascript">
function ChangeCourse(courseid)
{
 	val = courseid.options[courseid.options.selectedIndex].value;

}

</script>

<form action="talkto.jsp" method=post name=FORMtest>

    <div align="left">
	  <p><br>想對哪一門課的小主人說話？</br>
	    <select name=courseid onChange="ChangeCourse(document.selection.courseid)" size="1">
      		<option>==============</option>
		    <%
		    rs.first();
		    do{
		    %>
		    <option value="<%=rs.getString("C_No")%>"><%=rs.getString("C_Name")%></option>
		    <%}while(rs.next());%>
	    </select>	    
	  </p>
	  <p align="left">

	  </p>
    </div> 
    
    <div >
      <p>要說的話：
      <select name=type size="1">
      	<option value = "0">加油</option>
      	<option value = "1">關心</option>
      	<option value = "2">祝福</option>
      </select>
		<INPUT type="text" name=record></INPUT>
	    <INPUT type="submit" value="送出" name=submitTalk></INPUT>
	    <INPUT type="reset" value="清除" name=clear></INPUT>"
	  </p>
    
    </div> 

</form>

</body>
</html>